package com.maikang.exammall.task.async;

import com.maikang.exammall.repository.CartRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Component
@RequiredArgsConstructor
@Log4j2
public class CartAsyncTask {
    private final CartRepository cartRepository;

    @Async("threadPoolTaskExecutor")
    @Transactional(rollbackFor = Exception.class)
    public void deleteCartsByIds(Iterable<Long> ids) {
        cartRepository.deleteAllById(ids);
    }
}
